<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
		<title>疫情分析系统</title>
		<link rel="stylesheet" href="./res/layui/css/layui.css">
		<link rel="stylesheet" href="./res/static/css/index.css">
		<link rel="icon" href="./images/favicon.ico">
		<script src="./api/config.js"></script>
		<script src="./highCharts/jquery-3.2.1.js"></script>
	</head>
	<body>

		<!-- nav部分 -->
		<div class="nav index">
			<div class="nav-logo">
				<a href="./status.html">
					<img src="./res/static/img/logo.png" width="65" style="margin-left: 20px;">
				</a>
			</div>

			<div class="layui-container">
				<div class="nav-list">
					<ul class="layui-nav" lay-filter="" style="margin: 0 -35px;">
						<li class="layui-nav-item"><a href="status.html">疫情现状</a></li>
						<li class="layui-nav-item layui-this"><a href="nat.html">核酸检测</a></li>
						<li class="layui-nav-item"><a href="news.html">疫情新闻</a></li>
						<li class="layui-nav-item"><a href="virus.html">专题展示</a></li>
						<li class="layui-nav-item"><a href="way.html">出行速查</a></li>
						<li class="layui-nav-item"><a href="resident.html">居民上报</a></li>
						<li class="layui-nav-item"><a href="hospital.html">医院速查</a></li>
					</ul>
				</div>
			</div>
		</div>

		<!-- main -->
		<div class="main-news">

			<!-- <div class="layui-container">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
					<legend>个人核酸情况查询</legend>
				</fieldset>
				<form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
							<label class="layui-form-label">居民编号</label>
							<div class="layui-input-inline">
								<input type="text" name="residentId" lay-verify="required" autocomplete="off" class="layui-input" placeholder="例如：张三">
							</div>
						</div>           
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn1"><i class="layui-icon"></i> 搜 索</button>
							<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="traif-search"><i class="layui-icon"></i> 查 询</button> -->
						<!-- </div>
                    </div>
				
						
				<table class="layui-hide" id="currentTableId1" lay-filter="currentTableFilter1"></table>
			</div>  -->


			<div class="layui-container">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
					<legend>核酸检测机构速查</legend>
				</fieldset>
				<form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">检测地点</label>
                            <div class="layui-input-inline">
                                <input type="text" name="sitesAddress" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">医院编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="hospitalId" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!-- hospitalId  sitesName -->
                        <div class="layui-inline">
                            <label class="layui-form-label">医生编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="doctorId" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
				<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
			</div>
		</div>

		<div style="height: 350px;">
		</div>
		<script src="./res/layui/layui.js"></script>
		<script>
			layui.use(['form', 'table'], function () {
				var $ = layui.jquery,
					form = layui.form,
					table = layui.table;
		
				table.render({
					elem: '#currentTableId',
					url: 'http://localhost:8080/natsites/sitesList',
					//toolbar: '#toolbarDemo',
					defaultToolbar: ['filter', 'exports', 'print', {
						title: '提示',
						layEvent: 'LAYTABLE_TIPS',
						icon: 'layui-icon-tips'
					}],
					cols: [[
						{field: 'sitesName',  title: '名称', align: "center"},
						{field: 'sitesAddress', width: 200, title: '地点', align: "center"},
						{field: 'hospitalId',  title: '医院编号', align: "center"},
						{field: 'doctorId', title: '医生编号', align: "center"},
					]],
					// limits: [5, 10, 15,20],
					// limit: 5,
					// page: true,
					// skin: 'line'
				});
				table.render({
							elem: '#currentTableId1',
					url: 'http://localhost:8080/natinfo/infotList',
					toolbar: '#toolbarDemo',
					defaultToolbar: ['filter', 'exports', 'print', {
						title: '提示',
						layEvent: 'LAYTABLE_TIPS',
						icon: 'layui-icon-tips'
					}],
					cols: [[
						{field: 'infoId',  title: '报告编号'},
						{field: 'infoTime', title: '检测时间'},
						{field: 'infoResult', title: '检测结果'},
						{field: 'residentId', title: '人员编号'},
					]],
					limits: [5, 10, 15,20],
					limit: 5,
					// page: true,
					skin: 'line'
				});
		
				// 监听搜索操作
				form.on('submit(data-search-btn)', function (data) {
					var result = JSON.stringify(data.field);
					// layer.alert(result, {
					// 	title: '最终的搜索信息'
					// });
		
					//执行搜索重载
					table.reload('currentTableId', {
						// page: {
						// 	curr: 1
						// }
						where: {
							sitesAddress: data.field.sitesAddress,
							hospitalId: data.field.hospitalId ,
							doctorId: data.field.doctorId,
						}
					}, 'data');
					return false;
				});
				// 监听搜索操作
				form.on('submit(data-search-btn1)', function (data) {
					var result = JSON.stringify(data.field);
					layer.alert(result, {
						title: '最终的搜索信息'
					});
		
					//执行搜索重载
					table.reload('currentTableId1', {
						page: {
							curr: 1
						}
						, where: {
							residentId: data.field.residentId,
							// hospitalId: data.field.hospitalId ,
							// sitesName: data.field.sitesName,
						}
					}, 'data');
					return false;
				});
		
				/**
				 * toolbar监听事件
				 */
				table.on('toolbar(currentTableFilter)', function (obj) {
					if (obj.event === 'add') {  // 监听添加操作
						var index = layer.open({
							title: '添加用户',
							type: 2,
							shade: 0.2,
							maxmin:true,
							shadeClose: true,
							area: ['100%', '100%'],
							content: './sites/add.html',
							end:function(index){
									table.reload('currentTableId');
								}
						});
						$(window).on("resize", function () {
							layer.full(index);
						});
					} else if (obj.event === 'delete') {  // 监听删除操作
						var checkStatus = table.checkStatus('currentTableId'), data = checkStatus.data;
						// layer.alert(JSON.stringify(data));
						//遍历json数据,得到属性
						var str = "";
						for (var key in data) {
							str += data[key].sitesId + "-";
						}
						var data2 = {"str":str};
						$.ajax({
								url: "http://localhost:8080/natsites/deleteAllSites",
								data: data2,
								type: 'post',
								success: function (data) {
									if (data.code == 200) {
										parent.layer.msg("删除成功")
										table.reload("currentTableId")
									}
								},
								error: function(data){
									layer.alert("删除失败")
								}
						});
						obj.del();
						layer.close(index);
					}
				});
		
				//监听表格复选框选择
				table.on('checkbox(currentTableFilter)', function (obj) {
					console.log("obj -----      "+obj);
					var data = obj.data;
					console.log("objdata -----      "+data);
		
				});
		
				table.on('tool(currentTableFilter)', function (obj) {
					var data = obj.data;
					console.log(data);
					if (obj.event === 'edit') {
		// 传递数据
					localStorage.setItem("objects",JSON.stringify(data));
		
						var index = layer.open({
							title: '编辑用户',
							type: 2,
							shade: 0.2,
							maxmin:true,
							shadeClose: true,
							area: ['100%', '100%'],
							content: './sites/edit.html',
							end:function(index){
									table.reload('currentTableId');
								}
						});
						$(window).on("resize", function () {
							layer.full(index);
						});
						return false;
					} else if (obj.event === 'delete') {
						layer.confirm('真的删除行么', function (index) {
							$.get("http://localhost:8080/natsites/deleteNatSites",{id:data.sitesId},function(result){
									if(result.code==200){
										layer.msg("删除成功");
										obj.del();   //删除对应的  tr  删除页面上的dom 结构
									}         
								},"json");
								table.reload('currentTableId');    
								layer.close(index);
						});
					}
				});
		
			});
		</script>
		<script>
			layui.config({
				base: './res/static/js/'
			}).use('firm');

            layui.config({
                base: './mods/', version: '1.0'
            });

            layui.use(['form','layer', 'layarea', 'laydate'], function () {
                var $ = layui.jquery,
                    form = layui.form,
                    layarea = layui.layarea,
                    laydate = layui.laydate;

                layarea.render({
                    elem: '#area-picker',
                    change: function (res) {
                        console.log(res);
                    }
                });

                //日期时间选择器
                laydate.render({
                    elem: '#test5'
                    ,type: 'datetime'
                });

                form.on('submit(place-search)', function (data) {
                    data.field.area = data.field.county;
                    $.ajax({
                        url: RequestUrl('/userInfo/formPage'),
                        data:{"searchParams":JSON.stringify(removeObjectEmptyKey(data.field))},
                        type:"Post",
                        dataType:"json",
                        success:function(data){
                            if (data && data.count > 0) {
                                layer.alert("您的感染风险较大, 请尽快前往定点门诊进行检测!");
                            } else {
                                layer.alert("您很安全!");
							}
                        },
                        error:function(data){
                            layer.alert("查找失败!")
                        }
                    });

                    return false;
				});

                form.on('submit(traif-search)', function (data) {
                    $.ajax({
                        url: RequestUrl('/userWay/formQuery'),
                        data:{"time":data.field.time, "number":data.field.number},
                        type:"Post",
                        dataType:"json",
                        success:function(data){
                            if (data && data.count > 0) {
                                layer.alert("您的感染风险较大, 请尽快前往定点门诊进行检测!");
                            } else {
                                layer.alert("您很安全!");
                            }
                        },
                        error:function(data){
                            layer.alert("查找失败!")
                        }
                    });

                    return false;
                });
            });
		</script>
	</body>
</html>
